{% extends 'base.html' %}
{% load crispy_forms_tags %}

{% block title %}管理分类和标签 - 个人博客{% endblock %}

{% block content %}
    <div class="container py-4" xmlns="http://www.w3.org/1999/html">
        <div class="row">
            <!-- 分类管理 -->
            <div class="col-md-6 mb-4">
                <div class="card shadow-sm">
                    <div class="card-header bg-primary text-white d-flex justify-content-between align-items-center">
                        <h2 class="h4 mb-0">分类</h2>
                    </div>
                    <div class="card-body">
                        <div class="table-responsive">
                            <table class="table table-hover">
                                <thead>
                                <tr>
                                    <th>名称</th>
                                    <th>文章数</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                {% for category in categories %}
                                    <tr>
                                        <td>
                                            <a href="{% url 'category_detail' category.slug %}"
                                               class="text-decoration-none">{{ category.name }}</a>
                                        </td>
                                        <td>{{ category.post_count }}</td>
                                        <td>
                                            <a href="{% url 'category_detail' category.slug %}"
                                               class="btn btn-sm btn-outline-primary">
                                                <i class="fas fa-eye"></i>
                                            </a>
                                        </td>
                                    </tr>
                                {% empty %}
                                    <tr>
                                        <td colspan="3" class="text-center">暂无分类</td>
                                    </tr>
                                {% endfor %}
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>

            <!-- 标签管理 -->
            <div class="col-md-6 mb-4">
                <div class="card shadow-sm">
                    <div class="card-header bg-secondary text-white d-flex justify-content-between align-items-center">
                        <h2 class="h4 mb-0">标签</h2>

                    </div>
                    <div class="card-body">
                        <div class="table-responsive">
                            <table class="table table-hover">
                                <thead>
                                <tr>
                                    <th>名称</th>
                                    <th>文章数</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                {% for tag in tags %}
                                    <tr>
                                        <td>
                                            <a href="{% url 'tag_detail' tag.slug %}"
                                               class="text-decoration-none">{{ tag.name }}</a>
                                        </td>
                                        <td>{{ tag.post_count }}</td>
                                        <td>
                                            <a href="{% url 'tag_detail' tag.slug %}"
                                               class="btn btn-sm btn-outline-primary">
                                                <i class="fas fa-eye"></i>
                                            </a>
                                        </td>
                                    </tr>
                                {% empty %}
                                    <tr>
                                        <td colspan="3" class="text-center">暂无标签</td>
                                    </tr>
                                {% endfor %}
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock %}

